function halvingSum(n) {
    var sum = 0;
    for (var i = 0;(temp = parseInt(n / 2 ** i)) > 0; i++, sum += temp);
    return sum;
}
console.log(halvingSum(25))